<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<script type="text/javascript">
/* 
	$("li").each(function(){
		vat that = this;//这个this是指一个dom元素 getElementById();   
		that.className;
		var $this  = $(this);//$().addClass(),removeClass()  
		$this.attr("class")
	}); */


	
	//this代表对象本身
	function Person(name){
		this.name = name;
		this.say = function(){
			console.log(this.name);
		}
		this.sayAge = function(){
			console.log(this.age);
		}
	}
	
	
	var person = new Person("wang");
	var person2 = new Person("wang2");
	
	person.say();
	person.sayAge();
	person.age = 20;
	person.sayAge();
	
	//这里方法中的this代表window对象
	Person("window");
	
	//this 并不能嵌套传递下去
	var obj = {
			title:"wang kun ming",
			say:function(){
				console.log(this.title);
			},
			hellow:function(){
				console.log(this.title);
				var that = this;
				function hellowSay(){
					console.log(that.title);
				}
				hellowSay();
			}
	}
	obj.say();
	obj.hellow();
	
</script>
</body>
</html>